/*
 * token.h	Special tokens.
 *
 * $Id: token.h,v 1.6 2000/08/25 14:55:56 aland Exp $
 *
 */

#include "radius_cdef.h"
#ifndef DICT_H
#define DICT_H

RADIUS_BEGIN_DECL


#  define VENDORPEC_USR		429
	/*
 *	Initialize the dictionary.
 */

#ifdef WITH_DICT_NOCASE
#define DICT_STRCMP strcasecmp
#else
#define DICT_STRCMP strcmp
#endif

typedef struct dict_attr {
	char		name[32];
	int			attr;
	int			type;
	int			vendor;
	int			inum;
	struct dict_attr	*next;
} DICT_ATTR;

typedef struct dict_value {
	char		name[32];
	char		attrname[32];
	int			attr;
	int			value;
	struct dict_value	*next;
} DICT_VALUE;

typedef struct dict_vendor {
	char		vendorname[32];
	int			vendorpec;
	int			vendorcode;
	struct dict_vendor	*next;
} DICT_VENDOR;


static DICT_ATTR	*dictionary_attributes = NULL;
static DICT_VALUE	*dictionary_values = NULL;
static DICT_VENDOR	*dictionary_vendors = NULL;


static int		vendorno = 1;
static const char *dtypes[] = {
	"string",
	"integer",
	"ipaddr",
	"date",
	"abinary",
	"octets",
	NULL,
};
/*
 *	Quick pointers to the base 0..255 attributes.
 *
 *	These attributes are referenced a LOT, especially during
 *	decoding of the on-the-wire packets.  It's useful to keep a
 *	cache of their dictionary entries, so looking them up is
 *	O(1), instead of O(N).  (N==number of dictionary entries...)
 */
static DICT_ATTR *base_attributes[256];
/*
 *	Dictionary functions.
 */
int		dict_addvendor(const char *name, int value);
int		dict_addattr(const char *name, int vendor, int type, int value);
int		dict_addvalue(const char *namestr, char *attrstr, int value);
int		dict_init(const char *dir, const char *fn);
DICT_ATTR	*dict_attrbyvalue(int attr);
DICT_ATTR	*dict_attrbyname(const char *attr);
DICT_VALUE	*dict_valbyattr(int attr, int val);
DICT_VALUE	*dict_valbyname(int attr, const char *val);
int		dict_vendorcode(int);
int		dict_vendorpec(int);
int		dict_vendorname(const char *name);


#define dict_attrget	dict_attrbyvalue
#define dict_attrfind	dict_attrbyname
#define dict_valfind	dict_valbyname


RADIUS_END_DECL

#endif 
